package net.comm.shequ.db;


import java.sql.ResultSet;
import java.sql.SQLException;


import net.comm.blog.bean.BaseBlog;
import net.comm.param.bean.BaseProperty;
import net.comm.shequ.bean.BaseShequ;
import net.comm.util.StringUtil;

import org.apache.log4j.Logger;
import org.sakaiproject.db.api.SqlReader;

public class DbShequService implements SqlReader
{

	static Logger logger = Logger.getLogger(DbShequService.class.getName());

	/**
	 * Read from the result one set of fields to create a Resource.
	 * 
	 * @param result
	 *        The Sql query result.
	 * @return The Resource object.
	 */
	public Object readSqlResultRecord(ResultSet result)
	{
		try
		{		
			
			int villageID = result.getInt(1);	//	社区ID
			String village = StringUtil.getValue(result.getString(2));	//	社区名称
			String info = StringUtil.getValue(result.getString(3));	//	社区介绍
			int work_location = result.getInt(4);		//	所在省份
			int work_sublocation = result.getInt(5);	//	所在城市
			int work_area = result.getInt(6);	//	所在区县
			String mapXY = StringUtil.getValue(result.getString(7));	//	Google地图位置
			String address = StringUtil.getValue(result.getString(8));	//	通讯地址
			String postCode = StringUtil.getValue(result.getString(9));	//	邮编
			int groupNum = result.getInt(10);	//	部落数量
			int memberNum = result.getInt(11);	//	成员人数
			String ctime = StringUtil.getValue(result.getString(12));	//	建立时间
			int userID = result.getInt(13);		//	创建人ID
			String status = StringUtil.getValue(result.getString(14));	//	状态
			String mtime = StringUtil.getValue(result.getString(15));	//	最后修改时间			

			// create the Resource from these fields
			return new BaseShequ( villageID,  village,  info, work_location,  work_sublocation,  work_area,
					 mapXY,  address,  postCode,  groupNum,	 memberNum,  ctime,  userID,  status,  mtime );
		}
		catch (SQLException e)
		{
			logger.error("读取表数据持久层失败！");
			return null;
		}
		
	}
}
